GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / OMRDetectOvalMarks Method / OMRDetectOvalMarks(Int32,Rectangle[],Int32) Method
GdPicture image identifier.
Array of Rectangle. This parameter is used as a reference to the location of the OMR Fields. Where each Rectangle in the Areas, corresponds to a rectangle surrounding a single OMR field. For example, if 10 Rectangles exist in Areas, there will be 10 OMR Fields to be investigated whether they were checked (filled) or not.
Number of Rectangles sent to the method. Basically, the length of Areas().
Example





In This Topic
OMRDetectOvalMarks(Int32,Rectangle[],Int32) Method
In This Topic
Returns whether a selected OMR (Optical Mark Recognition) field/s is filled or not. This method is mainly used for Oval shaped Fields. An OMR field can be a checkbox, a fill-in-area checkbox, areas on a multiple choice examination form, or any area where highlighting is required to indicate a certain choice.
Syntax
'Declaration
 
Public Overloads Function OMRDetectOvalMarks( _
   ByVal ImageID As Integer, _
   ByVal Areas() As Rectangle, _
   ByVal AreasCount As Integer _
) As Integer()
public int[] OMRDetectOvalMarks( 
   int ImageID,
   Rectangle[] Areas,
   int AreasCount
)
public function OMRDetectOvalMarks( 
    ImageID: Integer;
    Areas: Rectanglearray of;
    AreasCount: Integer
): array of Integer; 
public function OMRDetectOvalMarks( 
   ImageID : int,
   Areas : Rectangle[],
   AreasCount : int
) : int[];
public: int[]* OMRDetectOvalMarks( 
   int ImageID,
   Rectangle[]* Areas,
   int AreasCount
) 
public:
array<int>^ OMRDetectOvalMarks( 
   int ImageID,
   array<Rectangle>^ Areas,
   int AreasCount
) 

Parameters

ImageID
GdPicture image identifier.
Areas
Array of Rectangle. This parameter is used as a reference to the location of the OMR Fields. Where each Rectangle in the Areas, corresponds to a rectangle surrounding a single OMR field. For example, if 10 Rectangles exist in Areas, there will be 10 OMR Fields to be investigated whether they were checked (filled) or not.
AreasCount
Number of Rectangles sent to the method. Basically, the length of Areas().

Return Value

The method returns an Array of integers. If the value of an element is 0, then the field was not filled. If the value of an element is 1, then the field was filled. The Elements of the returned array will correspond to the Elements of the Rectangles Array Areas(). Where if the first element of the returned array[0] is 0, then the OMR field surrounded by the rectangle in the element of Areas[0] was not filled. Similarly, if the first element of the returned array[5] is 1, then the OMR field surrounded by the rectangle in the element of Areas[5] was filled.
Remarks

All Rectangles sent to the method via array Areas can be of any size or location, as long as they: 1. Surround the OMR Field completely. 2. Do not intersect with borders of OMR field. 3. Do not intersect with other objects in the document.

Closer, more accurate selection of those rectangles will yield faster and more accurate results.

If many documents are scanned of the same form, and the scanning position (due to translation) or quality is not guaranteed, the GdPicture Anchoring System can be used to specify the translation made to each document from the one where the user selected their Areas(surrounding rectangles). Then you can manually change the rectangle arrays to each document via the data provided.

To obtain best and most accurate results, images have to be of good quality, at least 200 dpi is recommended.

This method is used in the "OMR" Demo.

Example
Testing whether a selected OMR (Optical Mark Recognition) field/s is filled or not within a tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", false);
 
    // Specifying rectangles for OMR.
    const int markCount = 3;
    Rectangle[] areas = new Rectangle[markCount];
    // Each mark uses a quadruplet for its location (left, top, width, height).
    areas[0] = new Rectangle(850, 1580, 30, 30); // First area left, top, width, height.
    areas[1] = new Rectangle(850, 1620, 30, 30); // Second area left, top, width, height.
    areas[2] = new Rectangle(850, 1660, 30, 30); // Third area left, top, width, height.
 
    int[] filled = gdpictureImaging.OMRDetectOvalMarks(imageID, areas, markCount);
 
    StringBuilder result = new StringBuilder();
    for (int index = 0; index < markCount; index++)
    {
        result.AppendLine("Index:" + index.ToString());
        result.AppendLine("Left:" + areas[index].X.ToString());
        result.AppendLine("Top:" + areas[index].Y.ToString());
        result.AppendLine("Width:" + areas[index].Width.ToString());
        result.AppendLine("Height:" + areas[index].Height.ToString());
        result.AppendLine("Filled:" + filled[index].ToString());
        result.AppendLine();
    }
 
    MessageBox.Show(result.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
 
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also